Reduce "start-up" time for tasks in CeleryExecutor#11372
Merged
ashb merged 1 commit intoapache:masterfrom Oct 9, 2020
Merged
Conversation
This is similar to apache#11327, but for Celery this time. The impact is not quite as pronounced here (for simple dags at least) but takes the average queued to start delay from 1.5s to 0.4s
kaxil
approved these changes
Oct 9, 2020
mik-laj
approved these changes
Oct 9, 2020
turbaszek
reviewed
Oct 9, 2020
|
|
||
|
|
||
| def _execute_in_fork(command_to_exec: CommandType) -> None: | ||
| pid = os.fork() |
Member
There was a problem hiding this comment.
Do we need to fork it? Shouldn't we just execute it in current process (celery worker process)?
Member
Author
There was a problem hiding this comment.
Can't cos of the logging.shutdown() at the end of task_run (which we need to keep, as that's when remote logs are uploaded. #11327 (comment)
ashb
added a commit
to astronomer/airflow
that referenced
this pull request
Oct 12, 2020
This is about is about a 20% speed up for short running tasks! This change doesn't affect the "duration" reported in the TI table, but does affect the time before the slot is freeded up from the executor - which does affect overall task/dag throughput. (All these tests are with the same BashOperator tasks, just running `echo 1`.) **Before** ``` Task airflow.executors.celery_executor.execute_command[5e0bb50c-de6b-4c78-980d-f8d535bbd2aa] succeeded in 6.597011625010055s: None Task airflow.executors.celery_executor.execute_command[0a39ec21-2b69-414c-a11b-05466204bcb3] succeeded in 6.604327297012787s: None ``` **After** ``` Task airflow.executors.celery_executor.execute_command[57077539-e7ea-452c-af03-6393278a2c34] succeeded in 1.7728257849812508s: None Task airflow.executors.celery_executor.execute_command[9aa4a0c5-e310-49ba-a1aa-b0760adfce08] succeeded in 1.7124666879535653s: None ``` **After, including change from apache#11372** ``` Task airflow.executors.celery_executor.execute_command[35822fc6-932d-4a8a-b1d5-43a8b35c52a5] succeeded in 0.5421732050017454s: None Task airflow.executors.celery_executor.execute_command[2ba46c47-c868-4c3a-80f8-40adaf03b720] succeeded in 0.5469810889917426s: None ```
ashb
added a commit
that referenced
this pull request
Oct 13, 2020
#11373) * Spend less time waiting for LocalTaskJob's subprocss process to finish This is about is about a 20% speed up for short running tasks! This change doesn't affect the "duration" reported in the TI table, but does affect the time before the slot is freeded up from the executor - which does affect overall task/dag throughput. (All these tests are with the same BashOperator tasks, just running `echo 1`.) **Before** ``` Task airflow.executors.celery_executor.execute_command[5e0bb50c-de6b-4c78-980d-f8d535bbd2aa] succeeded in 6.597011625010055s: None Task airflow.executors.celery_executor.execute_command[0a39ec21-2b69-414c-a11b-05466204bcb3] succeeded in 6.604327297012787s: None ``` **After** ``` Task airflow.executors.celery_executor.execute_command[57077539-e7ea-452c-af03-6393278a2c34] succeeded in 1.7728257849812508s: None Task airflow.executors.celery_executor.execute_command[9aa4a0c5-e310-49ba-a1aa-b0760adfce08] succeeded in 1.7124666879535653s: None ``` **After, including change from #11372** ``` Task airflow.executors.celery_executor.execute_command[35822fc6-932d-4a8a-b1d5-43a8b35c52a5] succeeded in 0.5421732050017454s: None Task airflow.executors.celery_executor.execute_command[2ba46c47-c868-4c3a-80f8-40adaf03b720] succeeded in 0.5469810889917426s: None ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is similar to #11327, but for Celery this time.
The impact is not quite as pronounced here (for simple dags at least)
but takes the average queued to start delay from 1.5s to 0.4s
Closes #6905 - the config option added for LocalExecutor is used here too.
Data on this for a simple 10-task sequential DAG:
This was discovered in my general benchmarking and profiling of the scheduler for AIP-15, but it's not tied to any of that work. There are more of these kind of improvements coming, each unrelated but all add up.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.